<?php
    $rand=rand(1000,9999);
    $username=$_POST['username'];
    $pass=$_POST['password'];
    $password=MD5(MD5($pass).$rand);
if ($username&&$password!="") {
    $mysqli=mysqli_connect('localhost','root','root','user');
    $select="select * from user1 where username='$username'";
    $obj=mysqli_query($mysqli,$select);
    $arr=mysqli_fetch_array($obj);
    if (count($arr)>0){
        echo 1;
    }else{
        $time=date("Y-m-d H:i:s");
        $into="insert into user1 (username,password,date,rand) values('$username','$password','$time','$rand')";
        mysqli_query($mysqli, $into);
        $id=mysqli_insert_id($mysqli);
        $int="insert into user2 (uid) value ('$id')";
        mysqli_query($mysqli, $int);
        echo 5;//注册成功
    }
} else{echo 6;}

